const express = require('express');
const handle = require('../router_handle/register_handle');
const app = express.Router();
const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, path.join(__dirname, '../uploads/avator'));
	},
	filename: function (req, file, cb) {
		cb(null, 'avator' + new Date().valueOf() + path.extname(file.originalname));
	}
})
const upload = multer({
	storage
});

// 管理员注册(post)
// /register/admin
// username(4-12) password(4-12)
app.post('/admin', handle.admin);
// 用户注册(post)
// /register/user
// username(4-12) password(4-12) nickname(1-10) sex avator create_time 必传   introduction 不必传
app.post('/user', upload.single('avator'), handle.user);

module.exports = app